//********************************************************************************************************************//
//ORGANIZATION:
//AUTHOR: bpeng(bogers.peng@gmail.com)
//SUMMARY:
//********************************************************************************************************************//
#ifndef NATIVE_DOMAIN_COMPILING_SQL_PROCEDURE_H
#define NATIVE_DOMAIN_COMPILING_SQL_PROCEDURE_H

#ifndef NATIVE_DOMAIN_COMPILING_COMMON_FIELD_H
#include "Domain/Compiling/Common/Field.h"
#endif

namespace Native { namespace Compiling { namespace Sql
{
    //****************************************************************************************************************//
    //CProcedure
    //
    //****************************************************************************************************************//
    NATIVE_DECLARE_CONST_OBJECT(CArgument, C_ARGUMENT);
    NATIVE_DECLARE_CONST_OBJECT(CProcedure, C_PROCEDURE);
    class NATIVE_LIBRARY_EXPORT CProcedure :
        public CField,
        public IEqualTo<CProcedure>
    {
        NATIVE_DECLARE_OBJECT;
        
        NATIVE_DECLARE_PROPERTY(public, public, CString, Owner, _owner);
        NATIVE_DECLARE_PROPERTY(public, public, CString, Name, _name);
        NATIVE_DECLARE_PROPERTY(public, public, CString, ReturnedVariable, _returned_variable);

    protected:
        CMap<CString,CArgument> _arguments;

    public:
        CProcedure();
        CProcedure(C_PROCEDURE& that);
        CProcedure(C_PROCEDURE&& that);
        virtual ~CProcedure();

        virtual wstring ToString() const;
        //
        virtual bool operator==(C_PROCEDURE& rvalue) const;
        virtual bool operator!=(C_PROCEDURE& rvalue) const;
        //
        virtual void Clear();
        virtual CString ToCode() const;

        void Append(C_ARGUMENT& argument) throw();
        CArray<CArgument> Query(C_STRING& name) const;

        C_PROCEDURE& operator=(C_PROCEDURE& rvalue);
    };
}}}

#endif